home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / August 96 / sending AEevents from container < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB  |  [TEXT/ttxt]

  1. Subject:     sending AEevents from container to embedded parts
  2. Sent:        8/6/96 8:03 AM
  3. Received:    8/6/96 8:53 AM
  4. From:        Pamela J Hayes, phayes@umich.edu
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8.  
  9. I am trying to set properties of embedded parts from the containing 
  10. part.  I used the advice given in the Scripting engineering note and 
  11. added the HasProperty(), SetProperty(), and GetProperty() methods to my 
  12. embedded part.  
  13.  
  14. I also followed the advice given in the OpenDoc ProgrammerUs Guide by 
  15. using the ODMessageInterface class and its CreatePartAddrDesc(), 
  16. CreateEvent(), and CreatePartObjSpec() methods to create my AppleEvent.  
  17. I also added to the embedded part  an TaeteU resource describing the 
  18. TsetdU event and the corresponding properties.
  19.  
  20. But when I send the AppleEvent to the proxy part, I get OSErr -1728 
  21. (errAENoSuchObject).  Being a novice to AppleEvents, I donUt know where 
  22. exactly I have made an error - in my direct object specifier, in my 
  23. TaeteU resource (which I am not even sure is necessary?), or in my 
  24. embedded partUs *Property() methods.
  25.  
  26. Below is the method which creates and sends the AppleEvent.  Thanks for 
  27. any help anybody can give!
  28.  
  29. Pam
  30.  
  31. -------
  32.  
  33. void ChangeProxyColorScheme  (Environment* ev, 
  34.                 CProxy* proxy,
  35.                 long colorScheme,
  36.                 CChecklistPart* part)
  37. {    
  38.   // Get message interface object
  39.   ODMessageInterface* msgInt = part->GetSession(ev)->GetMessageInterface(ev);
  40.     
  41.   // Get the address of the embedded part
  42.   FW_CDesc    partAddress;
  43.   ODPart*    embeddingPart = part->GetODPart(ev);
  44.   msgInt->CreatePartAddrDesc (ev, partAddress, embeddingPart);
  45.     
  46.   // Create a set-data event
  47.   FW_CAppleEvent event;
  48.   ODSShort result = msgInt->CreateEvent (ev, kAECoreSuite, kAESetData, 
  49. partAddress, 0, event);
  50.     
  51.   // The part
  52.   ODObjectSpec*     spec (NULL);
  53.   ODPart*         embeddedPart = proxy->AcquireEmbeddedPart(ev);
  54.   msgInt->CreatePartObjSpec (ev, &spec, embeddedPart);
  55.   FW_CDesc        partSpec (spec); 
  56.     
  57.   // the property
  58.   FW_CDesc     propIDSpec;
  59.   propIDSpec.PutType (pColorScheme);
  60.     
  61.   // Prop of thePart
  62.   FW_CDesc    theSpec;
  63.   FW_CreateObjSpecifier (cProperty, partSpec, formPropertyID, propIDSpec, 
  64. theSpec);
  65.     
  66.   // The data to set "it" to
  67.   FW_CDesc     newValue;
  68.   newValue.PutLongInteger (colorScheme);
  69.     
  70.   // Add parameters to Apple event
  71.   OSErr        err;
  72.   err = AEPutParamDesc (event, keyDirectObject, theSpec);
  73.   err = AEPutParamDesc (event, keyAEData, newValue);
  74.     
  75.   // Send the event
  76.   FW_CAppleEvent     reply;
  77.   FW_CEmbeddingFrame* embeddingFrame = (FW_CEmbeddingFrame*) 
  78. part->GetFrame();
  79.   ODFrame*         embeddedFrame = proxy->AcquireEmbeddedFrame (ev, 
  80. embeddingFrame);    // target?
  81.     
  82.   /*    Commented out so I can get the OSErr
  83.     msgInt->Send (ev,  embeddedFrame,  embeddingPart,  event, reply, 
  84.             kAENoReply,
  85.              kAENormalPriority, 
  86.             120);
  87.  
  88.   err = AESend (event,  reply,
  89.             kAENoReply,
  90.              kAENormalPriority, 
  91.              120, (AEIdleUPP)kODNULL,
  92.             (AEFilterUPP)kODNULL);
  93. }
  94.  
  95.  
  96.